package giab.weixin.web.queue;

import giab.weixin.web.xml.bean.Message;

import java.util.LinkedList;
import java.util.Queue;

import org.springframework.stereotype.Component;


@Component
public class MessageQueue {
	
	private MessageQueue(){}
	
	private static   Queue<Message> queue = new LinkedList<Message>();
	
	public static void put(Message msg){
		queue.add(msg);
		
	}
	
	public static int size(){
		return queue.size();
	}
	
	public static void clear(){
		queue.clear();
	}
	
	/**
	 * 移除并返问队列头部的元素
	 * @return
	 */
	public static Message getMessagePoll(){
		return queue.poll();
	}
	
	/**
	 *    返回队列头部的元素    
	 * @return
	 */
	public static Message getMessagePeek(){
		return queue.peek();
	}
	

}
